package dongbai.soft.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import dongbai.soft.utils.getUUID;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;

/**
 * @author SingDeer
 * @email
 * @date 2023-06-29 15:51:52
 */
@Data
@TableName("receipt")
@NoArgsConstructor
@AllArgsConstructor
public class ReceiptEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 回执唯一标识符
     */
    @TableId
    private String rid;
    /**
     * 订单标识符
     */
    private String oid;
    /**
     * 商品名
     */
    private String pname;
    /**
     * 商品数量
     */
    private Integer pnum;
    /**
     * 配送费
     */
    private BigDecimal deliverPrice;
    /**
     * 商品收益
     */
    private BigDecimal price;
    /**
     * 接收时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date receiveTime = new Date();
    /**
     * 分站ID
     */
    private String trid;

    public ReceiptEntity(Map<String, Object> maps) {
        this.rid = getUUID.get6UUID();
        this.oid = (String) maps.get("OID");
        this.trid = (String) maps.get("TRID");
        this.price = new BigDecimal(String.valueOf(maps.get("price")));
        this.pname = (String) maps.get("pName");
        this.deliverPrice = new BigDecimal(String.valueOf(maps.get("deliver_price")));
        this.pnum = (Integer) maps.get("pnum");
    }

}
